/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
var iScrollPos = 0;
var actuallPosition = 1; 

    showNews = function (){
        
        if(!$('.newsFoto').is(':visible')){
            setTimeout( "jQuery('.newsFoto').hide();",300 );
        $('.newsContent').textillate({in:{sync: true, effect: 'shake'}}).delay(300).textillate('in');
       $('.newsFoto').delay(300).fadeIn(1000); 
   }
       else if($('.newsFoto').is(':visible')){
           setTimeout( "jQuery('.newsFoto').hide();",300 );
           $('.newsContent').textillate({in:{sync: true, effect: 'shake'}}).delay(300).textillate('in');
       $('.newsFoto').delay(300).fadeIn(1000); 
    }};

$(document).ready(function() {
  $("div.screen[data-position='" + actuallPosition + "']").show();
  $('.upperMenu a').attr('data-placement', 'auto');
  $('.upperMenu a').tooltip();
  
  $('.changeScreen').click(function() {
    var screen = $(this).attr('data-toPosition');
    $("div.screen").fadeOut(300);
    setTimeout(function() {
      $("div.screen[data-position='" + screen + "']").fadeIn();
    }, 300);
  });
  
  
  
  $('a.icon[data-target="contact"]').click(function() {
    $('html,body').animate({
      scrollTop: $('.footer .contact').offset().top
    }, 2000);
  });
  
  
  
  $(window).scroll(function() {
    var iCurScrollPos = $(this).scrollTop();
    if (iCurScrollPos > iScrollPos) {
      var upperMenu = $('.upperMenu');
      upperMenu.addClass('leftMenu');
      upperMenu.removeClass('upperMenu');
      upperMenu.children('div').removeClass('container');
      upperMenu.children('div').children('div').removeClass('blocksContainer');
      $('.underText').hide();
      $('.screensContainer').css('padding', '100px 0px 50px');
    } 
    else {
      if(iCurScrollPos === 0){
        var leftMenu = $('.leftMenu');
        leftMenu.addClass('upperMenu');
        leftMenu.removeClass('leftMenu');
        leftMenu.children('div').addClass('container');
        leftMenu.children('div').children('div').addClass('blocksContainer');
        $('.underText').show();
        
      }
    }
    iScrollPos = iCurScrollPos;
  });

    $('.changeScreen.newsBtn').click(showNews);    
});